<?php

namespace App\Http\Controllers;

use App\Common\Constant\Status;
use Illuminate\Http\Request;

class ErrorController extends Controller
{

    /**
     * 404页面
     */
    public function __404(Request $request){
        $errorCode = session('errorCode');
        $errorMessage = session('errorMessage') ? : (String)status($errorCode);
        $content = <<<EOT
404错误
    错误码：{$errorCode}
    错误内容：{$errorMessage}
EOT;
        return nl2br($content);
    }

    /**
     * 503页面
     */
    public function __503(Request $request){
        $errorCode = session('errorCode');

        if ($errorCode == Status::USER_BEING_REVIEW){
            return view('auth/registerSuccess');
        }

        $errorMessage = session('errorMessage') ? : (String)status($errorCode);
        $content = <<<EOT
503错误
    错误码：{$errorCode}
    错误内容：{$errorMessage}
EOT;
        return nl2br($content);
    }

}
